//
//  NewCollectionViewCell.m
//  艾听歌
//
//  Created by dllo on 16/5/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NewCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@implementation NewCollectionViewCell
//初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //图片
        self.imageView = [[UIImageView alloc] init];

        [self.contentView addSubview:self.imageView];
        //标题
        self.titleLable = [[UILabel alloc] init];

        [self.contentView addSubview:self.titleLable];
        
//         歌手姓名
        self.nameLabel = [[UILabel alloc] init];

        [self.contentView addSubview:self.nameLabel];
        
    }
    return self;
}

//布局方法
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.imageView.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height - 40);
    
    self.nameLabel.frame = CGRectMake(0, self.imageView.frame.size.height, self.imageView.frame.size.width, 20);
    self.nameLabel.font = [UIFont systemFontOfSize:14];
    
    self.titleLable.frame = CGRectMake(0, self.imageView.frame.size.height + 20, self.imageView.frame.size.width, 20);
    
}
// 重写set方法
- (void)setNewCellModel:(MusicSmallModel *)NewCellModel
{
    _NewCellModel = NewCellModel;
    self.nameLabel.text = _NewCellModel.name;
    self.titleLable.text = _NewCellModel.desc;
    NSURL *url = [NSURL URLWithString:_NewCellModel.picUrl];
    [self.imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"hold.png"]];
}

@end
